﻿using System;
using System.Collections.Generic;
using System.Text;
using LogServices;
using ConfigServices;

namespace MailServices
{
    public class MailServiceImpl : IMailService
    {
        private readonly ILogProvider _logger;
        //private readonly IConfigService _configProvider;

        private readonly IConfigReader _configProvider;
        //public MailServiceImpl(ILogProvider logProvider, IConfigService configService)
        //{
        //    _logger = logProvider;
        //    _configProvider = configService;
        //}

        public MailServiceImpl(ILogProvider logProvider, IConfigReader configService)
        {
            _logger = logProvider;
            _configProvider = configService;
        }
        public void SendEmail(string title, string to, string body)
        {
            _logger.Loginfo("准备发送邮件...");

            string smtpServer = _configProvider.GetConfig("SmtpServer");
            string userName = _configProvider.GetConfig("UserName");
            string Password = _configProvider.GetConfig("Password");

            Console.WriteLine($"服务器地址:{smtpServer}\t用户名：{userName}\t密码：{Password}");
            Console.WriteLine($"发送邮件：title={title}\tto={to}\tbody={body}");
            _logger.LogError("发送邮件过程中发生错误示例。");
            _logger.Loginfo("邮件发送完成。");
        }
    }
}
